//-----------------------------------------------------------------------------
//  Copyright (C) 2005-2008 Thomas S. Ullrich 
//
//  This file is part of the Solitaire Mahjong project.
//
//  This file may be used under the terms of the GNU General Public License.
//  This project is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License.
//  
//  Author: Thomas S. Ullrich
//  Last update: June 1, 2007
//-----------------------------------------------------------------------------
#include "smTileItem.h"
 
bool smTileItem::mUpdateEnabled = true;

smTileItem::smTileItem(QGraphicsScene *scene,
	           const QImage *normal,
			   const QImage *highlight,
			   int id) : QGraphicsPixmapItem(0, scene)
{
//    setSize(normal.width(), normal.height());
    mNormalPixmap = QPixmap::fromImage(*normal);
    mHighlightPixmap = QPixmap::fromImage(*highlight);
    mTileId = id;
    mColumn = -1;
    mRow = -1;
    mLayer = -1;
    mXOffset = 0;
    mYOffset = 0;
    mIndex = -1;
    mIsHighlighted = false;
	setPixmap(mNormalPixmap);
}
 
smTileItem::~smTileItem()
{ /* noop */ }

void smTileItem::remove()
{
    hide();
}
 
void smTileItem::setHighlighted(bool val)
{
    mIsHighlighted = val;
    if (val)
        setPixmap(mHighlightPixmap);
    else
        setPixmap(mNormalPixmap);
    // scene()->update();
}
 
void smTileItem::undoRemove()
{
    show();
}

int smTileItem::width() const
{
    return mNormalPixmap.width();
}

int smTileItem::height() const
{
    return mNormalPixmap.height();
}

